< previous page page_550 next page >

Page 550
Listing 14.10. continued
   End If
   '
LocalExit:
   '
End Sub
In Listing 14.10, you attempt to open a file on a disk drive that has no disk (or has an open drive door). The error handler prompts the user to correct the problem and allows the user to try the operation again. If all goes well the second time, the program continues. The user also has an option to cancel the operation.
Save and run the project. When you click on the Media button, you should get results that look like those in Figure 14.10.
0550-01.jpg
Figure 14.10.
The results of a physical media error.
Program Code Errors
Another common type of error is the program code error. These errors occur as part of the Visual Basic code. Errors of this type cannot be fixed by users and are usually due to unanticipated conditions within the code itself. Error messages such as Variable Not Found, Invalid Object, and so on, create a mystery for most of your users. The best way to handle errors of this type is to tell the user to report the message to the programmer and close the program safely.
Database Errors with the Data Control
A very common type of error that occurs in database applications is the data-related error. These errors include those that deal with data type or field size problems, table access restrictions including read-only access, locked tables due to other users, and so on. Database errors fall into two groups. Those caused by attempting to read or write invalid data to or from

 
< previous page page_550 next page >

If you like this book, buy it!